<?php
	class SearchManager{
	
		public function validate($category,$str,$param1,$param2){
		
				if(($str!=""||$str!=null)&&($category!=""||$category!=null)&&($param1!=""||$param1!=null)&&($param2!=""||$param2!=null)){
					return true;
				}else{
					return false;
				}
		}

		public function searchStudent($category,$str,$param1,$param2){
		
			$conn = oci_connect("naiad", "1234", "localhost/XE");
			$nrows1=$nrows2=$nrows3=$nrows4=$nrows5=0;
			for($k=0;$k<sizeof($category);$k++){
			switch($category[$k]){
				
				case 1:
					if((strcmp($str,"snum"))==0){
						$a = oci_parse($conn, "select a.STUDENTNO,b.TERM,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.ROOMNO FROM STUDENT a, CHECK_IN b where a.STUDENTNO=b.STUDENTNO AND a.STUDENTNO like '".$param1."'");
					}else if((strcmp($str,"name"))==0){
						$a = oci_parse($conn, "select a.STUDENTNO,b.TERM,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.ROOMNO FROM STUDENT a, CHECK_IN b where a.STUDENTNO=b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
					}
					oci_execute($a);
					$nrows1 = oci_fetch_all($a, $results1);
					break;
				case 2: 
						if((strcmp($str,"snum"))==0){
							$b = oci_parse($conn, "select STUDENTNO,NAMEFIRST,NAMELAST,NAMEMIDDLE,BIRTHDATE,GENDER,CIVILSTATUS,LASTSCHOOL,LASTSCHOOLTYPE,RELIGION,CLASSIFICATION,STFAPBRACKET,SCHOLARSHIPS,ALLOWANCE,CELLNO,EMAIL,HOBBIES,HONORS,TALENTS,AILMENTS,MEDICATIONS,HOMEADDRESS,COURSE FROM STUDENT where STUDENTNO like '".$param1."'");
						}else if((strcmp($str,"name"))==0){
							$b = oci_parse($conn, "select STUDENTNO,NAMEFIRST,NAMELAST,NAMEMIDDLE,BIRTHDATE,GENDER,CIVILSTATUS,LASTSCHOOL,LASTSCHOOLTYPE,RELIGION,CLASSIFICATION,STFAPBRACKET,SCHOLARSHIPS,ALLOWANCE,CELLNO,EMAIL,HOBBIES,HONORS,TALENTS,AILMENTS,MEDICATIONS,COURSE,HOMEADDRESS FROM STUDENT where (NAMEFIRST like '".$param1."%' OR NAMELAST like '".$param2."')");
						}
						#echo "<script>alert(\"Pumasok\".$_SESSION['category'].")</script>";
						oci_execute($b);
						$nrows2 = oci_fetch_all($b, $results2);
						break;
				case 3: 
						if((strcmp($str,"snum"))==0){
							$c = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST,b.FATHERNAME,b.FJOB,b.FOFFICE,b.FINCOME,b.FLIFE,b.FEMPLOYER,b.FTELNUM,b.MOTHERNAME,b.MJOB,b.MOFFICE,b.MINCOME,b.MLIFE,b.MEMPLOYER,b.MTELNUM FROM STUDENT a, PARENTS b where a.STUDENTNO = b.STUDENTNO AND b.STUDENTNO like '".$param1."'");
						}else if((strcmp($str,"name"))==0){
							$c = oci_parse($conn, "select  a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST,b.FATHERNAME,b.FJOB,b.FOFFICE,b.FINCOME,b.FLIFE,b.FEMPLOYER,b.FTELNUM,b.MOTHERNAME,b.MJOB,b.MOFFICE,b.MINCOME,b.MLIFE,b.MEMPLOYER,b.MTELNUM FROM STUDENT a, PARENTS b where a.STUDENTNO = b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
						}
						oci_execute($c);
						$nrows3 = oci_fetch_all($c, $results3);
						break;
				case 4: 
						if((strcmp($str,"snum"))==0){
							$d = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE,a.NAMELAST,b.NAME,b.ADDRESS,b.TELNO FROM STUDENT a, GUARDIAN b where a.STUDENTNO = b.STUDENTNO AND b.STUDENTNO like '".$param1."'");
						}else if((strcmp($str,"name"))==0){
							$d = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE,a.NAMELAST,b.NAME,b.ADDRESS,b.TELNO FROM STUDENT a, GUARDIAN b where a.STUDENTNO = b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");						
						}
						oci_execute($d);
						$nrows4 = oci_fetch_all($d, $results4);
					break;
				case 5: 
						if((strcmp($str,"snum"))==0) $e = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE,a.NAMELAST,b.TERM,b.DATE_IN,b.ROOMNO,b.DATE_OUT FROM STUDENT a, CHECK_IN b where a.STUDENTNO = b.STUDENTNO AND b.STUDENTNO like '".$param1."'");
						else if((strcmp($str,"name"))==0) $e = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE,a.NAMELAST,b.TERM,b.DATE_IN,b.ROOMNO,b.DATE_OUT FROM STUDENT a, CHECK_IN b where a.STUDENTNO = b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
						oci_execute($e);
						$nrows5 = oci_fetch_all($e, $results5);
					break;
				}
				}
			
			if((strcmp($str,"snum"))==0){
						$n = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, a.COURSE, a.COLLEGE, b.ROOMNO FROM STUDENT a, CHECK_IN b where a.STUDENTNO=b.STUDENTNO AND a.STUDENTNO like '".$param1."'");
					}else if((strcmp($str,"name"))==0){
						$n = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, a.COURSE, a.COLLEGE, b.ROOMNO FROM STUDENT a, CHECK_IN b where a.STUDENTNO=b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
					}
					oci_execute($n);
					$nrows9 = oci_fetch_all($n, $results9);
			
			
			
			if($nrows1!=0||$nrows2!=0||$nrows3!=0||$nrows4!=0||$nrows5!=0){
						for($j=0;$j<sizeof($category);$j++){
						echo "<table width='100%' border='0' cellpadding='1' >";
						
						if($j==0){
						echo "<tr><td >&nbsp;</td><td>&nbsp;</td><td >&nbsp;</td></tr>";
						echo "<tr><td class=confirm width='45%'><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results9['STUDENTNO'][$j] . "</td></tr>";
						echo "<tr><td class=confirm><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results9['NAMEFIRST'][$j] . " " . $results9['NAMEMIDDLE'][$j] . " " . $results9['NAMELAST'][$j] .  "</td></tr>";
						echo "<tr><td class=confirm><b>COURSE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results9['COURSE'][$j] ."</td></tr>";
						echo "<tr><td class=confirm><b>COLLEGE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results9['COLLEGE'][$j] ."</td></tr>";
						}
						
						if($category[$j]==1){
							echo "<tr><td ><h2 class=red>Room Number</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							for ($i = 0; $i < $nrows1; $i++ ) {
							
							  echo "<tr><td class=confirm width='45%'><b>TERM</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results1['TERM'][$i] . " SEMESTER</td></tr>";
							  echo "<tr><td class=confirm width='45%'><b>ROOM NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results1['ROOMNO'][$i] . "</td></tr>";
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							}
						
						}else if($category[$j]==2){
							
							for ($i = 0; $i < $nrows2; $i++ ) {
							  echo "<tr><td ><h2 class=red>Basic Information</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  //echo "<tr><td class=confirm width='45%'><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['STUDENTNO'][$i] . "</td></tr>";
							  //echo "<tr><td class=confirm><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['NAMEFIRST'][$i] . " " . $results2['NAMEMIDDLE'][$i] . " " . $results2['NAMELAST'][$i] .  "</td></tr>";
							  echo "<tr><td class=confirm width='45%'><b>COURSE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['COURSE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>HOME ADDRESS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['HOMEADDRESS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>BIRTHDAY</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['BIRTHDATE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>GENDER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['GENDER'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>CIVIL STATUS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['CIVILSTATUS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>LAST SCHOOL ATTENDED</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['LASTSCHOOL'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>SCHOOL TYPE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['LASTSCHOOLTYPE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>RELIGION</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['RELIGION'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>CLASSIFICATION</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['CLASSIFICATION'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>STFAP BRACKET</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['STFAPBRACKET'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>SCHOLARSHIP</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['SCHOLARSHIPS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>ALLOWANCE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['ALLOWANCE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>CELLPHONE NO.</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['CELLNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>EMAIL ADDRESS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['EMAIL'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>HOBBIES</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['HOBBIES'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>HONORS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['HONORS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>TALENTS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['TALENTS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>AILMENTS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['AILMENTS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>MEDICATIONS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results2['MEDICATIONS'][$i] . "</td></tr>";
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							}
						}else if($category[$j]==3){

						
							for ($i = 0; $i < $nrows3; $i++ ) {
							  echo "<tr><td ><h2 class=red>Parents</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  //echo "<tr><td class=confirm width='45%'><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['STUDENTNO'][$i] . "</td></tr>";
							  //echo "<tr><td class=confirm><b>NAME</b></td><td>&nbsp;</td><td class=confirm1>".$results3['NAMEFIRST'][$i] . " " . $results3['NAMEMIDDLE'][$i] . " " . $results3['NAMELAST'][$i] .  "</td></tr>";
							  echo "<tr><td class=confirm width='45%'><b>FATHER'S NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FATHERNAME'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>OCCUPATION</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FJOB'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>OFFICE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FOFFICE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>INCOME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FINCOME'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>STATUS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FLIFE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>EMPLOYER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FEMPLOYER'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>TEL NO.</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['FTELNUM'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>MOTHER'S NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MOTHERNAME'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>OCCUPATION</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MJOB'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>OFFICE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MOFFICE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>INCOME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MINCOME'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>STATUS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MLIFE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>EMPLOYER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MEMPLOYER'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>TEL NO.</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results3['MTELNUM'][$i] . "</td></tr>";
							echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							}
						
						}else if($category[$j]==4){
						
							for ($i = 0; $i < $nrows4; $i++ ) {
							  echo "<tr><td ><h2 class=red>Guardian</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  //echo "<tr><td class=confirm width='45%'><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results4['STUDENTNO'][$i] . "</td></tr>";
							  //echo "<tr><td class=confirm ><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results4['NAMEFIRST'][$i] . " " . $results4['NAMEMIDDLE'][$i] . " " . $results4['NAMELAST'][$i] .  "</td></tr>";
							  echo "<tr><td class=confirm width='45%'><b>GUARDIAN'S NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results4['NAME'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>ADDRESS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results4['ADDRESS'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>CONTACT NO.</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results4['TELNO'][$i] . "</td></tr>";
							 echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							}
	
						
						}else if($category[$j]==5){
							
							echo "<tr><td ><h2 class=red>Check-in</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							for ($i = 0; $i < $nrows5; $i++ ) {
							
							  //echo "<tr><td class=confirm width='45%'><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results5['STUDENTNO'][$i] . "</td></tr>";
							  //echo "<tr><td class=confirm><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results5['NAMEFIRST'][$i] . " " . $results5['NAMEMIDDLE'][$i] . " " . $results5['NAMELAST'][$i] .  "</td></tr>";
							  echo "<tr><td class=confirm width='45%'><b>SEMESTER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results5['TERM'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>DATE IN</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results5['DATE_IN'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm><b>ROOM NO.</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results5['ROOMNO'][$i] . "</td></tr>";
							   echo "<tr><td class=confirm><b>DATE OUT</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results5['DATE_OUT'][$i] . "</td></tr>";
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							}
							}
							
						}
						echo '</table><br/>';
						echo '<table width="100%" border="0" cellpadding="1">';
						echo '<tr>';
						echo '<td>';
						echo '<td>';
						echo '<a href="searchForm.php">Search Menu</a>';
						echo '</td>';
						echo '<td/>';
						echo '</tr>';
						echo '</table>';
						return 1;
					
					
				}else{
					return 0;
				}
			
				
		}
		
		
		public function searchPayment($str,$param1,$param2){
			
			$conn = oci_connect("naiad", "1234", "localhost/XE");
				if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.RECEIPTNO,b.TERM,b.PERIODCOVERED,b.DORMFEE,b.APPLIANCEFEE,b.TRANSFEE,b.DATEPAID,b.REMARKS FROM STUDENT a, PAYMENT b where a.STUDENTNO=b.STUDENTNO AND b.STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.RECEIPTNO,b.TERM,b.PERIODCOVERED,b.DORMFEE,b.APPLIANCEFEE,b.TRANSFEE,b.DATEPAID,b.REMARKS FROM STUDENT a, PAYMENT b where a.STUDENTNO=b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
				}
			
			oci_execute($s);
			$nrows = oci_fetch_all($s, $results);
			
			if($nrows!=0){
			
						echo "<table border='0' cellspacing='0' width='100%'>";
				
						
							for ($i = 0; $i < $nrows; $i++ ) {
							if($i==0){
							  echo "<td class=confirm width='45%'><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['STUDENTNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['NAMEFIRST'][$i] . " " . $results['NAMEMIDDLE'][$i] . " " . $results['NAMELAST'][$i] .  "</td></tr>";
							  }
							  echo "<tr><td ><h2 class=red>Payment # ".($i+1)."</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  echo "<tr><td class=confirm ><b>RECEIPT NO.</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['RECEIPTNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>SEMESTER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['TERM'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>PERIOD COVERED</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['PERIODCOVERED'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>DORM FEE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DORMFEE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>APPLIANCE FEE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['APPLIANCEFEE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>TRANSIENT FEE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['TRANSFEE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>DATE PAID</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DATEPAID'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>REMARKS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['REMARKS'][$i] . "</td></tr>";
	
							}
							
						echo '</table><br/>';
						echo '<table width="100%" border="0" cellpadding="1">';
						echo '<tr>';
						echo '<td>';
						echo '<td>';
						echo '<a href="searchPayment.php">Search Menu</a>';
						echo '</td>';
						echo '<td/>';
						echo '</tr>';
						echo '</table>';
						return 1;
					
				}else{
					return 0;
				}
						
			
		}
		
		public function searchViolation($str,$param1,$param2){
			
			$conn = oci_connect("naiad", "1234", "localhost/XE");
				if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.DATEVIOLATION,b.NATURE,b.ACTIONTAKEN,b.DATEREPORTED FROM STUDENT a, VIOLATION b where a.STUDENTNO=b.STUDENTNO AND b.STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.DATEVIOLATION,b.NATURE,b.ACTIONTAKEN,b.DATEREPORTED fROM STUDENT a, VIOLATION b where a.STUDENTNO=b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
				}
				
			
			oci_execute($s);
			$nrows = oci_fetch_all($s, $results);
			if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select * from CHECK_IN where STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select * from CHECK_IN where NAMELAST like '".$param2."' OR NAMEFIRST like '".$param1."'");
				}
			oci_execute($s);
			$exist = oci_fetch_all($s, $temp);
			if($exist > 0 and $nrows > 0){
				echo "<table border='0' cellspacing='0' width='100%'>";
				for ($i = 0; $i < $nrows; $i++ ) {
						
						if($i==0){
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							  echo "<tr><td class=confirm width='45%' ><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['STUDENTNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['NAMEFIRST'][$i] . " " . $results['NAMEMIDDLE'][$i] . " " . $results['NAMELAST'][$i] .  "</td></tr>";
							  }
							
							 echo "<tr><td ><h2 class=red>Violation # ".($i+1)."</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  echo "<tr><td class=confirm ><b>DATE OF VIOLATION</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DATEVIOLATION'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>NATURE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['NATURE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>ACTION TAKEN</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['ACTIONTAKEN'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>DATE REPORTED</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DATEREPORTED'][$i] . "</td></tr>";
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							
						
							}
						echo '</table><br/>';		
						echo '<table width="100%" border="0" cellpadding="1">';
						echo '<tr>';
						echo '<td>';
						echo '<td>';
						echo '<a href="searchViolation.php">Search Menu</a>';
						echo '</td>';
						echo '<td/>';
						echo '</tr>';
						echo '</table>';
						return 1;
					
				}
				else if($exist > 0 and $nrows == 0){
					echo "<table border='0' cellspacing='0' width='100%'>";
					echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
					echo "<tr><td class=confirm width='45%' ><b>NO RECORDS FOUND</b></td><td width='1%'>&nbsp;</td></tr>";
					echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
					echo '</table><br/>';		
					return 1;
				}
				else if($exist < 1){
					return 0;
				}
						
			
		}
		
		public function searchReservation($str,$param1,$param2){
			
			$conn = oci_connect("naiad", "1234", "localhost/XE");
				if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.TERM, a.ORNUM, a.DATERESERVED, a.AMOUNT, a.REMARKS, b.REMARKS, c.NAMEFIRST, c.NAMEMIDDLE, c.NAMELAST FROM RESERVATION a, KEYDEPOSIT b, STUDENT c where a.STUDENTNO=c.STUDENTNO AND a.STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.TERM, a.ORNUM, a.DATERESERVED, a.AMOUNT, a.REMARKS, b.REMARKS, c.NAMEFIRST, c.NAMEMIDDLE, c.NAMELAST FROM RESERVATION a, KEYDEPOSIT b, STUDENT c where a.STUDENTNO=c.STUDENTNO AND (c.NAMEFIRST like '".$param1."%' OR c.NAMELAST like '".$param2."')");
				}
			
			oci_execute($s);
			$nrows = oci_fetch_all($s, $results);
			if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select * from CHECK_IN where STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select * from CHECK_IN where NAMELAST like '".$param2."' OR NAMEFIRST like '".$param1."'");
				}
			oci_execute($s);
			$exist = oci_fetch_all($s, $temp);
			if($exist > 0 and $nrows > 0){
				echo "<table border='0' cellspacing='0' width='100%'>";
				
				for ($i = 0; $i < $nrows; $i++ ) {
						
						if($i==0){
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							  echo "<tr><td class=confirm width='45%' ><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['STUDENTNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['NAMEFIRST'][$i] . " " . $results['NAMEMIDDLE'][$i] . " " . $results['NAMELAST'][$i] .  "</td></tr>";
							  echo "<tr><td ><h2 class=red>Reservation Info</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  }
							
							  
							  echo "<tr><td class=confirm ><b>TERM</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['TERM'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>OFFICIAL RECEIPT NO</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['ORNUM'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>DATE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DATERESERVED'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>AMOUNT</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['AMOUNT'][$i] . "</td></tr>";
							  
							  echo "<tr><td class=confirm ><b>RESERVATION REMARKS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['REMARKS'][$i] . "</td></tr>";
							 
							  
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							  
							  
							
						
							}
						echo '</table><br/>';		
						echo '<table width="100%" border="0" cellpadding="1">';
						echo '<tr>';
						echo '<td>';
						echo '<td>';
						echo '<a href="searchReservation.php">Search Menu</a>';
						echo '</td>';
						echo '<td/>';
						echo '</tr>';
						echo '</table>';
						return 1;
					
				}else if($exist > 0 and $nrows == 0){
					echo "<table border='0' cellspacing='0' width='100%'>";
					echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
					echo "<tr><td class=confirm width='45%' ><b>NO RECORDS FOUND</b></td><td width='1%'>&nbsp;</td></tr>";
					echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
					echo '</table><br/>';		
					return 1;
				}
				else if($exist < 1){
					return 0;
				}
						
			
		}
		
		public function searchAppliance($str,$param1,$param2){
			
			$conn = oci_connect("naiad", "1234", "localhost/XE");
				if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.CONTROLNO,b.TYPE,b.TERM,b.DATEINSTALLED,b.DATECANCELLED,b.REMARKS FROM STUDENT a, APPLIANCE b where a.STUDENTNO=b.STUDENTNO AND b.STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select a.STUDENTNO,a.NAMEFIRST, a.NAMEMIDDLE, a.NAMELAST, b.CONTROLNO,b.TYPE,b.TERM,b.DATEINSTALLED,b.DATECANCELLED,b.REMARKS FROM STUDENT a, APPLIANCE b where a.STUDENTNO=b.STUDENTNO AND (a.NAMEFIRST like '".$param1."%' OR a.NAMELAST like '".$param2."')");
				}
			
			oci_execute($s);
			$nrows = oci_fetch_all($s, $results);
			if((strcmp($str,"snum"))==0){
						$s = oci_parse($conn, "select * from CHECK_IN where STUDENTNO like '".$param1."'");
				}else if((strcmp($str,"name"))==0){
						$s = oci_parse($conn, "select * from CHECK_IN where NAMELAST like '".$param2."' OR NAMEFIRST like '".$param1."'");
				}
			oci_execute($s);
			$exist = oci_fetch_all($s, $temp);
			if($exist > 0 and $nrows > 0){
				echo "<table border='0' cellspacing='0' width='100%'>";
				for ($i = 0; $i < $nrows; $i++ ) {
						
						if($i==0){
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							  echo "<tr><td class=confirm width='45%' ><b>STUDENT NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['STUDENTNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>NAME</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['NAMEFIRST'][$i] . " " . $results['NAMEMIDDLE'][$i] . " " . $results['NAMELAST'][$i] .  "</td></tr>";
							  }
							
							 echo "<tr><td ><h2 class=red>Appliance # ".($i+1)."</h2></td><td>&nbsp;</td><td >&nbsp;</td></tr>";
							  echo "<tr><td class=confirm ><b>CONTROL NUMBER</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['CONTROLNO'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>TYPE</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['TYPE'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>DATE INSTALLED</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DATEINSTALLED'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>DATE CANCELLED</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['DATECANCELLED'][$i] . "</td></tr>";
							  echo "<tr><td class=confirm ><b>REMARKS</b></td><td width='1%'>&nbsp;</td><td  class=confirm1>".$results['REMARKS'][$i] . "</td></tr>";
							  echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
							
						
							}
						echo '</table><br/>';		
						echo '<table width="100%" border="0" cellpadding="1">';
						echo '<tr>';
						echo '<td>';
						echo '<td>';
						echo '<a href="searchAppliance.php">Search Menu</a>';
						echo '</td>';
						echo '<td/>';
						echo '</tr>';
						echo '</table>';
						return 1;
					
				}else if($exist > 0 and $nrows == 0){
					echo "<table border='0' cellspacing='0' width='100%'>";
					echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
					echo "<tr><td class=confirm width='45%' ><b>NO RECORDS FOUND</b></td><td width='1%'>&nbsp;</td></tr>";
					echo "<tr><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
					echo '</table><br/>';		
					return 1;
				}
				else if($exist < 1){
					return 0;
				}
						
			
		}
		
		
	}
	
?>